home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
L' Effet Pommier 3
/
L'Effet Pommier - Volume 03.iso
/
Programmation
/
PlayerPRO 4.5.1 Dev.Kit
/
MADH Library 4.01
/
Game.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-02-07
|
3KB
|
138 lines
/********************************************************/
/*
Player PRO 4.5 -- Music Driver EXAMPLE
Library Version 4.0
To use with MusicLibrary 4.0 for Think C & CodeWarrior
Antoine ROSSET
16 Tranchees
1206 GENEVA
SWITZERLAND
FAX: (41 22) 346 11 97
Compuserve: 100277,164
Internet: rosset@dial.eunet.ch
*/
/********************************************************/
#include "RDriver.h"
/*****************************/
/****** MAIN FUNCTION ********/
/*****************************/
void main( void)
{
OSErr iErr;
DialogPtr TheDia;
Handle itemHandle;
Rect itemRect;
short itemType, i, itemHit;
Handle mySound[ 4]; // my 4 sound resource
/* Initialisation de la toolbox */
InitGraf( &qd.thePort);
InitFonts();
InitWindows();
TEInit();
InitMenus();
InitCursor();
MaxApplZone();
/******************************************/
/*** Load and prepare my sound resource ***/
/******************************************/
for( i = 0 ; i < 4; i++)
{
mySound[ i] = GetResource( 'snd ', 128 + i);
DetachResource( mySound[ i]);
HLock( mySound[ i]); // VERY IMPORTANT !!!!!!
}
/*******************************************************************************************/
/****** MAD Library Initialisation : choose the best driver for the current hardware ******/
/****** ******/
/****** Standard initialization with 4 tracks... ******/
/*******************************************************************************************/
{
MADDriverSettings init;
init.numChn = 4;
init.outPutBits = 8;
init.outPutRate = rate22khz;
init.outPutMode = StereoOutPut;
init.driverMode = SoundManagerDriver;
init.antiAliasing = false;
init.repeatMusic = false;
init.sysMemory = false;
init.Interpolation = false;
init.MicroDelay = false;
init.MicroDelaySize = 0;
init.surround = false;
MADInitLibrary("\p");
if( MADCreateDriver( &init) != noErr) Debugger();
}
if( MADLoadMusicRsrc( 'MADH', 3214) != noErr) Debugger();
if( MADPlay() != noErr) Debugger();
/******************************************/
/*** Open my dialog ***/
/******************************************/
TheDia = GetNewDialog( 128,0L, (WindowPtr) -1L);
SetPort( TheDia);
do
{
ModalDialog( 0L, &itemHit);
switch( itemHit)
{
case 2:
MADDriver->Reading = !MADDriver->Reading;
GetDItem( TheDia, 2, &itemType, &itemHandle, &itemRect);
SetCtlValue( (ControlHandle) itemHandle, !GetCtlValue( (ControlHandle) itemHandle));
break;
case 3:
MADPlaySndHandle( mySound[ 0], 0, 48); // On track ID 0, C 3 = 48
break;
case 4:
MADPlaySndHandle( mySound[ 1], 1, 0xFF); // On track ID 0, 0xFF = normal rate
break;
case 5:
MADPlaySndHandle( mySound[ 2], 2, 36); // On track ID 1, at C 2 = 36
break;
case 6:
MADPlaySndHandle( mySound[ 3], 3, 60); // On track ID 2, at C 4 = 60
break;
}
}while( itemHit != 1);
DisposDialog( TheDia);
MADStop(); // Stop the driver
MADDisposeMusic(); // Clear music
MADDisposeDriver(); // Dispose driver
MADDisposeLibrary(); // Close Music Library
for( i = 0 ; i < 4; i++)
{
HUnlock( mySound[ i]);
DisposeHandle( mySound[ i]);
}
}